package server;

import game.Player;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Packet Interpreter. Acts as a base for interpreting game packets.
 * @author Twisty
 *
 */
public abstract class PacketInterpreter {

	// The player the packets correspond to.
	private Player player;
	
	/**
	 * Class constructor.
	 * @param player	The player associated with the packet.
	 */
	public PacketInterpreter(Player player) {
		this.player = player;
	}
	
	/**
	 * Get the player.
	 * @return The associated player.
	 */
	public Player getPlayer() {
		return this.player;
	}
	
	/**
	 * Interpret a JSON object. Needs to be overridden for specific game implementation.
	 * @param data				The data to interpret.
	 * @throws JSONException	Whenever parsing fails.
	 */
	public abstract void interpret(JSONObject data) throws JSONException;

}
